### FILE="Main.annotation"
# Copyright:	Public domain.
# Filename:	501_MISSION_CONTROL_PROGRAM.agc
# Purpose:	Part of the source code for Solarium build 55. This
#		is for the Command Module's (CM) Apollo Guidance
#		Computer (AGC), for Apollo 4.
# Assembler:	yaYUL --block1
# Contact:	Jim Lawton <jim DOT lawton AT gmail DOT com>
# Website:	www.ibiblio.org/apollo/index.html
# Page scans:	www.ibiblio.org/apollo/ScansForConversion/Solarium055/
# Mod history:	2009-09-26 JL	Created.

## Page 553

		SETLOC	64000
LIFTOFF		INHINT
		TC	READTIME +1	# SAVE TIME OF LIFTOFF
		CS	RUPTSTOR
		TS	TLIFTOFF
		CS	RUPTSTOR +1
		TS	TLIFTOFF +1

		COM
		TS	TBASE4

CALL4.11	CAF	ELEVEN
		TC	NEWPHASE
		OCT	00004

		CCS	A
		TC	SETLIFT
		TC	SETLIFT

		INHINT
		CAF	2SEC		# ALLOW 2 SECS FOR BACK-UP GRR COMPUTATION
		TC	WAITLIST
		CADR	TARGTASK

SETLIFT		TC	FLAG1UP
		OCT	00002

		TC	JAMTERM		# FLUSH V75 GRR BACKUP.

TARGTASK	CAF	THIRTY1
		TC	NEWPHASE
		OCT	00004

		CAF	ZERO
		TS	TBASE3

		CAF	ONE
		TC	NEWPHASE
		OCT	00003

		CAF	ZERO		# FIX UP TBASE5 FOR READACCS RESTART AND
		AD	TBASE5		#   LOAD 2 SECS INTO TIME COUNTERS (I.E.
		AD	TLIFTOFF +1	#   ZERO THE AGC CLOCK AT LIFT-OFF)
		AD	NEG1/2
		AD	NEG1/2
		XCH	TBASE5

		CAF	200DEC
		TS	TIME1

		CAF	THIRTY2
## Page 554
		TC	NEWPHASE
		OCT	00004

		CS	200DEC		# CALL ON BOOST MONITOR
		AD	TROLL +1
		TC	WAITLIST
		CADR	MON1TASK

REDO4.32	CAF	PRIO12
		TC	FINDVAC
		CADR	TARGJOB

		CAF	ZERO		# FINALLY ZERO TIME2
		TS	TIME2

		TC	TASKOVER

REDO4.31	CAF	PRIO35
		TC	NOVAC
		CADR	ENEMA

		TC	TARGTASK +3



		BANK	24

TARGJOB		TC	BANKCALL	# COMMAND IMUCDU TO ATT. CONTROL MODE
		CADR	IMUATTC

		TC	NEWMODE		# SET MAJOR MODE TO BOOST ATTITUDE MONITOR
		OCT	00011
		
		TC	SETHETAD	# FORCE THETAD,+1,+2 TO EWQUALS CDUX,Y,Z
		
		TC	INTPRET
		
		DSU	0		# TARGET VECTORS INITIALLY REFERENCED TO
			TLIFTOFF	# GRR. WILL NOW UPDATE THEM TO LIFT-OFF
			TIME2GR
		STORE	DTEAROT
		
		DMOVE	0
			TPACIF1
		STORE	TPACIFC
		
		DMOVE	0
			TATLAN1
		STORE	TATLANT
## Page 555
		VMOVE	0
			RTPACIF1
		STORE	RTINIT
		
		ITC	0
			EARROT1
		
		NOLOD	0
		STORE	RTPACIFC
		
		VMOVE	0
			RTATLAN1
		STORE	RTINIT
		
		ITC	0
			EARROT1
		
		NOLOD	0
		STORE	RTATLANT
		
		EXIT	0

TARGET		TC	BANKCALL	# WAIT FOR COMPLETION OF MODE SWITCH
		CADR	IMUSTALL
		TC	CURTAINS	# TRAP IF INCOMPLETE

		CS	ONE
		TC	NEWPHASE
		OCT	00004
		
		TC	ENDOFJOB

## Page 556

		BANK	32
		
MON1TASK	CAF	PRIO5
		TC	FINDVAC
		CADR	MONITJOB
		
		TC	FLAG1UP		# SET MONIT FLAG
MONITMSK	OCT	00040

		TC	TASKOVER



MONITJON	TC	PHASCHNG
		OCT	03203
		
		TC	INTPRET
		
		RTB	1		# FORM TIME SINCE START OF MONITOR
		DSU
			LOADTIME
			TPITCH
		STORE	TMONITOR	# SCALED AT 2(+28) CS
		
		NOLOD	2		# TEST IF TIME TO START PITCH MONITOR
		BPL	LODON
		DMOVE
			+3
			DPZERO		# NO
		STORE	TPMONITOR
		
PITCH1		NOLOD	3		# TEST IF TIME TO STOP MONITOR
		DSU	BMN
		LODON	DMOVE
		SWITCH
			TENDPTCH
			+4
			TENDPTCH	# IF IT IS, SET TMONITOR TO MAX AND REMOVE
			MONITFLG	#  MONIT FLAG
		STORE	TMONITOR
		
		DMOVE	2		# DO SIGN AGREE AND RESCALE TO 2(+14) CS
		RTB	TSLT
		RTB	TSLT
			TMONITOR
			SGNAGREE
			14D
			POLYENT1	# SOLVE PITCH POLYNOMIAL
			4
		STORE	20D		# CHI SCALED AT 1 REV.
## Page 557
		SIN	0
			20D
		
		DMOVE	0
			DPZERO
		
		COS	1
		VDEF
			20D
		STORE	22D		# UNIT VECTOR ALONG VEHICLE ROLL AXIS
		
		NOLOD	0
		STORE	XSCD
		
		DMOVE	0
			XSCD +4
		STORE	22D		# FORM VECTOR (XSCD +4, 0, -XSCD) AT 22D
		
		COMP	0
			XSCD
		STORE	26D
		
ROLLER		RTB	4		# FORM DESIRED ROLL EXCURSION
		DSU	DDV
		DSU	BMN
		LODON	DMOVE
		RTB
			LOADTIME
			TROLL
			1/RLLRTE
			MAXROLL
			+3
			SPZERO		# IF EXCLEEDS MAX VALUE, SET ROLL ATTITUDE
			FRESHPD		#   TO ZERO
		
		NOLOD	0
		STORE	20D		# ROLL ANGLE SCALED AT 1 REV.
		
		NOLOD	1
		SIN
		STORE	18D
		
		NOLOD	1
		TSLT	VXSC
			1
			22D
		STORE	YSCD
		
		COS	1
		COMP
## Page 558
			20D
		STORE	YSCD +2
		
		NOLOD	2
		COMP	VXSC
		VSLT
			22D
			1
		STORE	ZSCD
		
		DMOVE	0
			18D
		STORE	ZSCD +2
		
		ITC	0		# RESOLVE INTO NB COORDS.
			CALCSCNB
		
		ITC	0		# EXTRACT EULER ANGLES FROM XNB MATRIX
			CALCCDU
		
		NOLOD	0		# STORE THE ANGLES
		STORE	THETAD
		
		EXIT	0
		
		CAF	BIT6		# TEST IF MONIT FLAG SET
		MASK	FLAGWRD1
		CCS	A
		TC	MONITJOB	# IT IS. RECYCLE MONITJOB
		
		INHINT			# CALL TUMBLE MONITOR IN TTUMON SECS
		CS	TTUMON
		COM
		TC	WAITLIST
		CADR	TUMBTSK1
		
		CS	TIME1
		TS	TBASE3
		
		CAF	TWO
		TC	NEWPHASE
		OCT	00003
		
		TC	ENDOFJOB



POLYENT1	CAF	TWELVE		# RTB HERE PRIOR TO ENTERING ERASABLE FOR
		TS	POLYORDR	#   POLYNOMIAN
		TC	POLYENTR
## Page 559

TUMBTSK1	CAF	TWENTY7
		TC	NEWPHASE
		OCT	3
		
		CAF	PRIO22
		TC	FINDVAC
		CADR	TUMBJOB1
		
		TC	RESET1



TUMBJOB1	TC	BANKCALL	# SWITCH IMUCDU MODE TO FINE ALIGN
		CADR	IMUFINNW
		
		TC	BANKCALL	# WAIT FOR COMPLETION OF MODE SWITCH
		CADR	IMUSTALL
		TC	CURTAINS
		
		TC	NEWMODE		# SET MAJOR MODE TO TUMBLE MONITOR
		OCT	00014
		
		TC	INTPRET		# ...NO 01407 ALARMS, PLEASE...
		
		AXT,1	1
		ITC
			6
			CDUTRIG
		
		VMOVE	0
			CDUTEMP
		STORE	DUPCDU
		
		EXIT	0
		
		TC	ENDOFJOB
		
TUMBTASK	CAF	PRIO22
		TC	FINDVAC
		CADR	TUMBJOB
		
		CAF	BIT1		# TEST IF TUMBLE FLAG SET
		MASK	FLAGWRD1
		CCS	A
		TC	RESET1		# IT IS. CONTINUE TO MONITOR
		
		CS	FLAGWRD2	# TEST IF BURN IS TUMBLE ARREST (I.E. HAS
		MASK	BIT1		# CORRECTIVE ACTION STARTED)
		CCS	A
		TC	TUMTEST1	# IT HAS NOT
## Page 560
		CS	OUT1		# IT HAS. TEST IF ENGINE ON YET. IF NOT,
		MASK	BIT13		# WAIT BEFORE TURNING IT OFF AGAIN
		CCS	A
		TC	RESET1
		
		TC	POSTJUMP	# LEAP TO CUT SPS ENGINE
		CADR	ENGINOFF
		
TUMTEST1	CAF	NOTUMASK	# TEST IF NEXT BURN HAS BEEN SET
		MASK	FLAGWRD2
		CCS	A
		TC	TASK3OUT

RESET1		CAF	1SEC32		# RECALL IN 1 SEC
		TC	WAITLIST
		CADR	TUMBTASK
		
		TC	TASKOVER
		
TASK3OUT	CS	ONE
		TC	NEWPHASE
		OCT	00003
		
		TC	TASKOVER	# IT HAS. KILL TUMBLE MONITOR
		
NOTUMASK	OCT	00016		# (OR OF SPS1, ABRT, TABT)

## Page 561

		BANK	24

TUMBJOB		CAF	NOTUMSK1	# SKIP THIS JOB IF NEXT BURN HAS BEEN SET
		MASK	FLAGWRD2
		CCS	A
		TC	ENDOFJOB
		
		TC	INTPRET
		
		VMOVE	0		# SAVE PRESENT CDUX,Y,Z
			DUPCDU
		STORE	CDUBUF
		
		AXT,1	1		# FORM DP CDUX,Y,Z
		ITC
			6
			CDUTRIG
		
		VMOVE	0		# SAVE DUPLICATE CDUX,Y,Z
			CDUTEMP		# SCALED AT 1 REV
		STORE	DUPCDU
		
		NOLOD	1
		VSU	AXT,1
			CDUBUF
			6
		STORE	CDUTEMP
		
		ITC	0		# COMPUTE SIN OF CDUX,Y,Z
			SINCOS		# DIFFERENCES AND PUT IN SINCDU,+2,+4
		
		ABVAL	2
		DSU	BMN
		EXIT
			SINCDU
			CRIT
			NOTUMBLE
		
		TC	FLAG1UP		# SET TUMB FLAG
		OCT	00001
		
		TC	ENDOFJOB
		
NOTUMBLE	EXIT	0
		TC	FLAG1DWN	# REMOVE TUMBLE FLAG
		OCT	00001
		
		TC	ENDOFJOB
		
NOTUMSK1	OCT	16
## Page 562
CRIT		2DEC	0.010905	# SIN(5DEG/2) SCALED AT 2(+2)

## Page 563

		BANK	32



S4BSMSEP	CS	TIME1		# BRANCH HERE ON RECEIPT OF S4B/CSM SEP
		TS	TBASE4
		
		TC	FLAG1DWN	# RESET UPDAT FLAG
		OCT	20000
		
		TC	RELAYON		# SET SCS +X TRANS, ATTITUDE CONTROL MODE,
		OCT	40221		# GIMBAL MOT POWER DISCRETES (C27,23,30)
		
		CAF	BIT1		# TEST IF TUMB FLAG SET
		MASK	FLAGWRD1
		CCS	A
		TC	SETUMB2
		
		TC	FLAG1UP		# SET INTP FLAG
INTPMASK	OCT	01000

		TC	PHASCHNG
		OCT	01404
		
		INHINT
		CAF	1.7SEC		# WAIT 1.7 SECS FOR RECEIPT OF ABORT SIG.
		TC	WAITLIST
		CADR	ABRTWAIT

TRYGRAB		TC	GRABDSP		# TRY TO GRAB DISPLAY
		TC	CLEANOUT	# ALREADY GRABBED. FLUSH OUT GRABBER
		
		TC	FREEDSP		# WE HAVE IT. AND LET IT GO
		
SETS4SEP	TC	FLAG1UP		# SET S4BSM FLAG
		OCT	00200
		
		TC	ENDOFJOB
		
CLEANOUT	INHINT
		CAF	PRIO35		# MAKE HIGH PRIO JOB TO FLUSH OUT PINBALL
		TC	NOVAC
		CAD	ENEMA
		RELINT
		
		TC	SETS4SEP
		
ABRTWAIT	CAF	PRIO25		# CONTINUE WITH SAME PRIORITY AS S4BSMSEP
		TC	NOVAC
		CADR	ABORTEST
## Page 564
		TC	TASKOVER
		
ABORTEST	CAF	ONE		# SET VGCNTR FOR 2 PASSES THRU CALCVGB
		TS	VGCNTR
		
		TC	FLAG1DWN	# RESET UPDAT FLAG
		OCT	20000
		
		CAF	BIT14		# TEST IF ABORT SIGNAL RECEIVED
		MASK	STATE
		CCS	A
		TC	SETABORT	# IT WAS. BRANCH TO ABORT
		
		INHINT
		CAF	8.3SEC		# SET CALL TO TURN OFF +X 10 SEC AFTER SEP
		TC	WAITLIST
		CADR	PLUSXOFF
		RELINT
		
		TC	SETBRNSW	# SET BURN TO SPS1
SPS1MASK	OCT	00010

		CAF	SPS1LOC		# SET LOCATION FOR NOMINAL SPS1 VR COMP
		TS	VRCADR
		
		TC	PHASCHNG
		OCT	02504
		
REDO4.21	TC	NEWMODE		# SET MAJOR MODE TO PRE-SPS1
		OCT	00031
		
		TC	JAMTERM		# FLUSH V75 S4BSMSEP BACKUP.
		
SPS1LOC		CADR	501SPS1

SETABORT	TC	SETBRNSW	# SET BURN TO ABORT
		OCT	00002
		
		TC	PHASCHNG
		OCT	02004
		
		INHINT
		CAF	3.8SEC		# START ENGINE IN 4.3 SECS
		TC	WAITLIST
		CADR	ATTCNOFF
		RELINT
		
REDO4.16	TC	BANKCALL	# SET IMU TO ATT. CONTROL MODE
		CADR	IMUATTC
## Page 565
		TC	SETHETAD	# SET THETAD,+1,+2 TO AGREE WITH CDUX,Y,Z
		
		CAF	ABORTLOC	# SET LOCATION FOR ABORT VR COMPUTATIONS
		TS	VRCADR
		
		CAF	TWO		# SET VGCNTR FOR THREE PASSES THROUGH
		TS	VGCNTR		# CALCVGB BEFORE ISSUING STEER COMMANDS
		
		CAF	35DEG		# SET THRUST ANGLE TO 35 DEG ABOVE HORIZON
		TS	LOOKANG
		
		TC	FLAG1UP		# SET STEER FLAG FOR ABORT STEERING
		OCT	00010
		
		TC	NEWMODE		# SET MAJOR MODE TO ABORT BURN
		OCT	00073
		
		TC	BANKCALL	# WAIT FOR MODE SWITCH TO COMPLETE
		CADR	IMUSTALL
		TC	CURTAINS	# CATCH-ALL FOR FAILURE TO IMU MODE SWITCH
		
		TC	JAMTERM		# FLUSH OUT V75
		
ABORTLOC	CADR	501ABORT

SETUMB2		TC	SETBRNSW	# SET BURN TO TUMBLE ARREST
ARRSTMSK	OCT	00001

		CAF	FIFTN
		TC	NEWPHASE
		OCT	4
		
		INHINT
		CAF	2.5SEC		# START ENGINE AT 3.0 SECS AFTER SEP.
		TC	WAITLIST	# SEPARATION
		CADR	ATTCNOFF
		RELINT
		
		TC	NEWMODE		# SET MAJOR MODE TO TUMBLE ARREST BURN
		OCT	00074
		
		TC	TRYGRAB
		
ABORTRPT	TC	STATEUP		# COME HERE ON RECEIPT OF UPLINK ABORT
		OCT	20000		#   VERB, NOUN. SET THE ABORT SIGNAL
		
		TC	RELAYON		# SET SCS BACKUP ABORT DISCRETE (C33)
		OCT	42000
		
		TC	ENDOFJOB
## Page 566
8.3SEC		DEC	830
1.7SEC		DEC	170
93.8SEC		DEC	9380
10.5SEC		DEC	1050
3.8SEC		DEC	380

## Page 567

GIMPOWON	TC	RELAYON		# SET SCS GMP DISCRETE (C30)
		OCT	40200
		
		CAF	TWENTY4
		TC	NEWPHASE
		OCT	00004
		
		CS	TIME1
		TS	TBASE4
		
		CAF	TWENTY5
		TC	NEWPHASE
		OCT	00004
		
		CAF	11.5SEC
		TC	WAITLIST
		CADR	ATTCNOFF
		
		TC	TASKOVER
		
ATTCNOFF	CAF	EIGHTN
		TC	NEWPHASE
		OCT	00004
		
		CS	TIME1
		TS	TBASE4
		
		TC	RELAYOFF	# REMOVE SCS ATT. CONTROL DISCRETE (C23)
		OCT	40001
		
		CAF	NINETEEN
		TC	NEWPHASE
		OCT	00004
		
		CAF	0.25SEC
		TC	WAITLIST
		CADR	DVMODEON
		
		TC	TASKOVER
		
DVMODEON	TC	RELAYON		# SET SCS DV MODE DISCRETE (C24)
		OCT	40002
		
		CAF	TWENTY0
		TC	NEWPHASE
		OCT	00004
		
		CAF	0.25SEC
		TC	WAITLIST
		CADR	ENGINEON
## Page 568
		TC	TASKOVER
		
TASK4OUT	CS	ONE
		TC	NEWPHASE
		OCT	00004
		
		TC	TASKOVER
		
ENGINEON	CS	BIT13		# SET BIT13, OUT1 TO 1  (ENGINE ON)
		TS	DVCNTR		# MUST BE NEGATIVE INITIALLY
		MASK	OUT1
		AD	BIT13
		TS	OUT1
		
		TC	READTIME +1
		CS	RUPTSTOR
		TS	TENGON
		CS	RUPTSTOR +1
		TS	TENGON +1
		
		TC	FLAG1UP		# SET DVMON, STEER FLAGS
		OCT	00030
		
		CAF	TWENTY4		# SEE IF THIS EITHER A SPS1 OR SPS2 BURN
		MASK	FLAGWRD2
		CCS	A
		TC	+2		# YES
		TC	TUMTEST2	# NO
		
		CCS	PHASE2		# TEST FOR PHASE2 VALUE.
		AD	NEG3		# WAS IT GREATER THAN 4 ORIGINALLY...
		CCS	A		# TEST NEW SUM.
		TC	ROLLTASK -3
		TC	ROLLTASK -3	# GOES UNLESS PHASE2 WERE +1,2,3, OR 4.
		TC	+1		# 1,2 OR 3 FALL IN HERE
		
		CS	ONE		# +4 COMES HERE
		TC	NEWPHASE	# IN WHICH CASES, WE MAKE GROUP 2 INACTIVE
		OCT	2
		
		CAF	PRIO35		# AND THEN FLUSH OUT EVERYTHING.
		TC	NOVAC
		CADR	ENEMA		# FORCE A PROGRAMMED RESTART
		
		TC	ROLLTASK -3



3OR4TEST	CAF	SPS34MSK
		MASK	FLAGWRD2
## Page 569
		CCS	A
		TC	+2
		TC	TUMTEST2	# IT IS NOT
		
		CAF	TWENTY3
		TC	NEWPHASE
		OCT	00004
		
		CAF	3SEC		# SHUT ENGINE DOWN IN 3 SECS
		TC	WAITLIST
		CADR	ENGINOFF
		
STEEROFF	TC	FLAG1DWN
STEERMSK	OCT	00010

		TC	TASKOVER
		
TUMTEST2	CAF	ARRSTMSK	# TEST IF BURN IS TUMBLE ARREST
		MASK	FLAGWRD2
		CCS	A
		TC	STR4OUT
		
		CAF	TWENTY2
		TC	NEWPHASE
		OCT	4
		
ROLLTASK	CS	FLAGWRD1	# TEST IF STEER FLAG SET
		MASK	STEERMSK
		CCS	A
		TC	TASKOVER	# IT IS NOT. KILL ROLLTASK
		
		CAF	PRIO10		# SUBMIT JOB TO DO ROLL STEERING
		TC	FINDVAC
		CADR	ROLLJOB
		
REDO4.22	CAF	5SEC32		# RECALL ROLLTASK IN 5 SECS
		TC	WAITLIST
		CADR	ROLLTASK
		
		TC	TASKOVER
		
STR4OUT		TC	FLAG1DWN
		OCT	00010
		
		TC	TASK4OUT
		
PLUSXOFF	TC	RELAYOFF	# REMOVE SCS +X TRANS DISCRETE (C27)
		OCT	40020
		
		TC	FLAG1UP		# SET INITFLAG TO ENABLE MANEUVER TO SPS1
## Page 570
		OCT	00400		#   BURN ATTITUDE
		
		CAF	89.5SEC		# START ENGINE IN 90 SECS
		TC	WAITLIST
		CADR	ATTCNOFF
		
		CAF	THIRTEEN
		TC	NEWPHASE
		OCT	00004
		
		TC	TASKOVER
		
0.25SEC		DEC	25
1SEC32		DEC	100
2.5SEC		DEC	250
3SEC		DEC	300
3.5SEC		DEC	350
5SEC32		DEC	500
6SEC		DEC	600
15SEC		DEC	1500
89.5SEC		DEC	8950
SHDNMSK		EQUALS	BIT12
SPS34MSK	OCT	00140

## Page 571

ENGINOFF	CS	BIT13		# SET ENGINE OFF
		MASK	OUT1
		TS	OUT1
		
		TC	READTIME +1	# SAVE TIME OF CUTOFF
		CS	RUPTSTOR
		TS	TCUTOFF
		CS	RUPTSTOR +1
		TS	TCUTOFF +1
		
		TC	FLAG1DWN	# DISABLE DV MONITOR
		OCT	00020
		
		CS	PIPAX		# SAVE DELTAV AT ENGINE OFF TIME.
		TS	VAVEGON
		CS	PIPAY
		TS	VAVEGON +1	# USE VAVEGON AREA FOR THIS.
		CS	PIPAZ
		TS	VAVEGON +2
		
		TC	RELAYOFF	# REMOVE SCS +X TRANS DISCRETE (C27)
		OCT	40020
		
		CS	FLAGWRD2	# TEST IF THAT WAS A TUMBLE BURN
		MASK	ARRSTMSK
		CCS	A
		TC	SPS1TEST
		
		CAF	ONE
		TS	VGCNTR
		
		TC	FLAG1UP		# SET INTP,INIT FLAGS
		OCT	01400
		
		CAF	BIT14		# TEST IF ABORT SIGNAL RECEIVED
		MASK	STATE
		CCS	A
		TC	VRCAD		# IT WAS, JUMP TO DO TUMBLE ABORT BURN
		
		CAF	93.8SEC		# START ENGINE IN 94.3 SECS
		TC	WAITLIST
		CADR	ATTCNOFF
		
		CAF	SPS1LOC		# SET LOCATION FOR NOMINAL SPS1 VR COMP
		TS	VRCADR
		
		CAF	PRIO25		# ESTABLISH MORE PRE-SPS1 BURN LOGIC
		TC	NOVAC
		CADR	REDO4.21
## Page 572

		CAF	THIRTEEN
		TC	NEWPHASE
		OCT	4

REDO4.13	TC	SETBRNSW	# SET BURN TO SPS1
		OCT	00010
		
		TC	TASK3OUT
		
VRCAD		CAF	ABORTLOC	# SET LOCATION TO ABORT VR COMPUTATION
		TS	VRCADR
		
		CAF	THREE
		TC	NEWPHASE
		OCT	00003
		
REDO3.3		TC	SETBRNSW	# SET BURN TO ABORT AFTER TUMBLE
TABTMASK	OCT	00004

		TC	TASKOVER
		
SPS1TEST	CAF	TWENTY8
		TC	NEWPHASE
		OCT	4
		
		CS	TCUTOFF +1
		TS	TBASE3
		TS	TBASE4
		
		CS	FLAGWRD2	# TEST IF THAT WAS A SPS1 BURN
		MASK	SPS1MASK
		CCS	A
		TC	SETMOD23
		
		CAF	10.5SEC		# CALL COAST PHASE IN 10.5 SECS
		TC	WAITLIST
		CADR	COASTPHS
		
		CAF	7SEC		# DUPLICATE GMPOFF SEQUENCE BEFORE SETTING
		TC	WAITLIST	# BURN SWITCH.  (FOR RESTART LOGIC.)
		CADR	GIMPOWOF
		
		CAF	FOUR		# 3.4 RESTART KEEPS POWER OFF SEQ. GOING
		TC	NEWPHASE
		OCT	3
		
		CAF	THREE
		TC	NEWPHASE
		OCT	00004

## Page 573

REDO4.3		TC	SETBRNSW	# SET BURN TO SPS2
SPS2MASK	OCT	00020

		TC	TASKOVER
		
SPS2TEST	CS	FLAGWRD2	# TEST IF THAT WAS A SPS2 BURN
		MASK	SPS2MASK
		CCS	A
		TC	SPS3TEST
		
		CAF	0.75SEC
		TC	WAITLIST
		CADR	CGTASK
		
		CAF	6SEC		# CALL FOR GMP ON IN 6 SECS
		TC	WAITLIST
		CADR	GIMPOWON
		
		CAF	SEVEN
		TC	NEWPHASE
		OCT	00003
		
		CAF	TEN
		TC	NEWPHASE
		OCT	00004
		
REDO4.10	TC	SETBRNSW	# SET BURN TO SPS3
SPS3MASK	OCT	00040

		TC	TASKOVER
		
SPS3TEST	CS	FLAGWRD2	# TEST IF THAT WAS A SPS3 BURN
		MASK	SPS3MASK
		CCS	A
		TC	SETMOD23	# IT WAS NOT. (EITHER A, TABT, OR SPS4)
		
		CAF	FOURTN
		TC	NEWPHASE
		OCT	00004
		
GMPON		CAF	6SEC		# CALL FOR ENGINE ON IN 10 SECS
		TC	WAITLIST
		CADR	GIMPOWON
		
REDO4.14	CAF	PRIO7
		TC	NOVAC
		CADR	MODE44
		
		TC	SETBRNSW	# SET BURN TO SPS4
SPS4MASK	OCT	00100
## Page 574
		TC	TASKOVER
		
SETMOD23	CAF	PRIO7		# MAKE JOB TO CHANGE MODE
		TC	NOVAC
		CADR	MODE23
		
		CAF	NINE
		TC	NEWPHASE
		OCT	00003
		
		CS	ONE
		TC	NEWPHASE
		OCT	00004
		
GMPOFF		CAF	7SEC
		TC	WAITLIST
		CADR	GIMPOWOF
		
		CAF	FOUR
		TC	NEWPHASE
		OCT	00003
		
		TC	TASKOVER
		
GIMPOWOF	CAF	3.5SEC		# CALL FOR DV MODE OFF IN 3.5 SECS
		TC	WAITLIST
		CADR	DVMODOFF
		
		TC	RELAYOFF
		OCT	40200
		
		CAF	FIVE
		TC	NEWPHASE
		OCT	00003
		
		TC	TASKOVER
		
GMPOFF3		TC	RELAYOFF	# REMOVE SCS GMP DISCRETE (C30)
		OCT	40200
		
		TC	TASK3OUT
		
DVMODOFF	TC	RELAYOFF	# REMOVE SCS DV MODE DISCRETE (C24)
		OCT	40002
		
		CAF	SIX
		TC	NEWPHASE
		OCT	00003
		
		CAF	0.25SEC
## Page 575
		TC	WAITLIST
		CADR	ATTCONON
		
		TC	TASKOVER
		
ATTCONON	TC	RELAYON		# SET SCS ATT. CONT. DISCRETE (C23)
		OCT	40001
		
		TC	TASK3OUT
		
MODE23		TC	NEWMODE		# SET MAJOR MODE TO ATTITUDE HOLD
		OCT	00023
		TC	ENDOFJOB
		
MODE44		TC	NEWMODE		# SET MAJOR MODE TO SPS4
		OCT	00044
		TC	ENDOFJOB



0.75SEC		DEC	75
1SEC		DEC	100
7SEC		DEC	700
11.5SEC		DEC	1150

## Page 576

		BANK	24
		
COASTPHS	TC	FLAG1UP		# GET SET TO START COASR PHASE ACTIVITY
COASTMSK	OCT	40000		# SET COAST FLAG

		CAF	289.5SEC +1	# SET TO LONGCALL TO FDAONTSK IN 289.5 SEC
		TS	LONGTIME +1
		CAF	289.5SEC
		TS	LONGTIME
		
		CAF	FDAILOC
		TS	CALLCADR
		
		TC	IBNKCALL	# MAKE WAITLIST CALL MORE THAN 120 SECS
		CADR	LONGCALL
		
		CAF	PRIO12		# ESTABLISH INITIAL VERTICAL JOB
		TC	FINDVAC
		CADR	SOAKINIT
		
		CAF	TWO
		TC	NEWPHASE
		OCT	00002
		
		CAF	FOUR
		TC	NEWPHASE
		OCT	00004
		
		TC	TASKOVER
		
FDAILOC		CADR	FDAONTSK
289.5SEC	2DEC	28950


FDAONTSK	TC	RELAYON		# SET SCS FDAI ALIGN DISCRETE (C31)
		OCT	40400
		
		CAF	10SEC
		TC	WAITLIST
		CADR	FDAOFTSK	# CALL FDAI OFF IN 10 SECS
		
		CAF	FIVE
		TC	NEWPHASE
		OCT	00004
		
		TC	TASKOVER
		
FDAOFTSK	CAF	-310SEC +1
		AD	TCOAST +1
## Page 577
		TS	LONGTIME +1
		
		CAF	ZERO
		AD	-310SEC
		AD	TCOAST
		TS	LONGTIME
		
		CAF	UPTSKLOC
		TS	CALLCADR
		
		TC	IBNKCALL
		CADR	LONGCALL
		
		CAF	SIX
		TC	NEWPHASE
		OCT	4
		
FDOFTSK1	TC	RELAYOFF	# REMOVE SCS FDAI ALIGN DISCRETE (C31).
		OCT	40400
		
		TC	TASKOVER
		
10SEC		DEC	1000
-310SEC		2DEC	-31000

UPTSKLOC	CADR	UPTASK



		BANK	14

CGTASK		CAF	PRIO21		# ESTABLISH CGJOB TO REMOVE ANGULAR CG
		TC	FINDVAC		# MOTION DEVELOPED DURING SPS2 BURN
		CADR	CGJOB
		
		CAF	1.25S14
		TC	WAITLIST
		CADR	GMPOFF3
		
		CAF	EIGHT
		TC	NEWPHASE
		OCT	3
		
		TC	TASKOVER
		
CGJOB		TC	NEWMODE		# SET MAJOR MODE TO SPS3 BURN
		OCT	00043
		
		TC	INTPRET

## Page 578
		VMOVE	1		# GET NOMINAL SPS2 CG CHANGE ABOUT IMU
		RTB	EXIT		# GIMBAL AXES INTO VAC, SCALED AT KE/2 REV
			DELCDU		# (KE =1.5), AND DECREMENT THETAD, +1, +2
			INCRCDUS
		
		TC	ENDOFJOB
		
1.25S14		DEC	125

		BANK	32
		
## Page 579

READACCS	CAF	PIPCADR		# BRANCH TO PIPA READ ROUTINE
		TC	ISWCALL
		
		CAF	TWO
		TC	NEWPHASE
		OCT	00005
		
REDO5.2		CS	PIPTIME +1
		TS	TBASE5
		
		CAF	TWO
		TS	PIPAGE
		
		CAF	ENTRYMSK	# TEST IF ENTRY FLAG SET
		MASK	FLAGWRD1
		CCS	A
		TC	SETUPENT
		
		CS	FLAGWRD1	# TEST IF COAST FLAG SET
		MASK	CSTMASK
		CCS	A
		TC	CCSHOLE
		TC	SETUPSOK	# IT IS. DO NOT RESET READACCS
		
		CAF	ABORT32		# TEST IF ABORT BURN IS SET. IF SO, NEED
		MASK	FLAGWRD2	# 2.5SECS COMPUTING INTERVAL
		CCS	A
		
		TC	CHANGEDT	# IT IS
		
		CAF	2SEC		# IT IS NOT. CALL READACCS IN 2 SECS
		TC	WAITLIST
		CADR	READACCS
		
MAKESERV	CAF	PRIO16		# ESTABLISH SERVICER ROUTINE
		TC	FINDVAC
		CADR	SERVICER
		
		CAF	THREE
		TC	NEWPHASE
		OCT	5
		
		TC	TASKOVER
		
SETUPENT	CAF	2SEC		# CALL ENTRY ROUTINES IN 2 SECS
		TC	WAITLIST
		CADR	PIPUP
		
		TC	MAKESERV
## Page 580

SETUPSOK	CAF	2SEC		# CALL SOAKTASK IN 2 SECS
		TC	WAITLIST
		CADR	SOAKTASK
		
		TC	MAKESERV
		
CHANGEDT	CAF	BIT1		# FORCE SERVICER TO SET DELTAT TO 2.5 SECS
		TS	DELTAV +1
		
		CAF	2.5SEC32	# CALL READACCS IN 2.5 SECS
		TC	MAKESERV -2
		
REREADAC	CAF	ABORT32		# READACCS RESTART LOCATION
		MASK	FLAGWRD2
		CCS	A
		TC	SET2.5S
		
CAFREPIP	CAF	REPIPCAD
		TC	READACCS +1
		
SET2.5S		CS	2.5SEC32
		AD	TBASE5
		AD	TIME1
		XCH	RUPTSTOR
		
		CCS	RUPTSTOR
		TC	CAFREPIP
		TC	CAFREPIP
		CAF	2.5SEC32
		AD	RUPTSTOR
		
		AD	POSMAX
		TS	A
		TC	CAFREPIP
		
		CS	RUPTSTOR
		TC	WAITLIST
		CADR	CAFREPIP
		
		TC	TASKOVER
		
PIPCADR		CADR	PIPASR
REPIPCAD	CADR	REPIPASR
CHDTMASK	EQUALS	BIT11
ENTRYMSK	EQUALS	BIT3
READMASK	EQUALS	BIT11
CSTMASK		OCT	40000
ABORT32		OCT	6
2.5SEC32	DEC	250
4SEC		DEC	400
## Page 581

SERVICER	TC	BANKCALL	# COMPENSATE THE PIPA DATA IN THE DELV
		CADR	1/PIPA		# REGISTERS/
		
		CS	STATE		# TEST IF PIPAS BIAS IS TO BE DISREGARDED
		MASK	BIT12
		CCS	A
		TC	REDO5.3		# NO
		
		TS	DELV		# YES, CLEAR OUT DELV AS LONG AS BIAS FLAG
		TS	DELV +1		#      IS SET.
		TS	DELV +2
		TS	DELV +3
		TS	DELV +4
		TS	DELV +5
		
REDO5.3		TC	INTPRET

		ITC	0		# SEE IF TIME FOR STATE VECTOR UPDATE.
			501UPCHK	# (501 & 2 ONLY).
		
REGSTEP		ITC	0
			CALCRVG

AVGRET		CAF	ELEVEN		# ROUTINE CYCLES 12 TIMES TO SAVE OLD VR,
AGAIN		TS	MPAC		#   VN FOR RESTARTS
		INDEX	MPAC
		CS	VR
		INDEX	MPAC
		TS	VR1		# (TEMPORARIES IN AMEMORY)
		CCS	MPAC
		TC	AGAIN
		
		CS	VGCNTR		# SAVE FOR RESTARTS
		TS	VGCNT1
		CS	DVCNTR
		TS	DVCNT1
		
		TC	PHASCHNG
		OCT	02705
		
RE5.23		TC	INTPRET

		TEST	0		# TEST IF ENTRY FLAG SET
			ENTRYFLG
			GETFF		# IT IS NOT
		DMOVE	0
			LAD
		STORE	INITL/D
		
		AXT,1	1
## Page 582
		TEST	AXT,1
			0
			ABORTSIG
			PACIFIC
			8D
PACIFIC		COMP*	0
			TPACIFC,1
		STORE	DTEAROT
		
		VMOVE*	0
			RTPACIFC,1
		STORE	RTINIT
		
		ITC	0
			EARROT1
		
		EXIT	0
		
		CAF	ZERO		# RESET DELTAT +1 TO ZERO
		TS	DELTAT +1
		
		TC	POSTJUMP	# GO TO ENTRY INITIALIZATION ROUTINE.
		CADR	STARTENT
		
GETFF		ITC	0		# COMPUTE TIME TO FREE-FALL TO RTERM
			CALCTFF

COASTEST	TEST	1		# TEST IF COAST FLAG SET
		VMOVE	VSRT
			COASTFLG
			TFFTEST
			RN		# IT IS. TRANSFER RN,VN TO ORBITAL
			RSCALE -15D
		STORE	RRECT		# INTEGRATION ROUTINE
		
		VMOVE	0
			VN
		STORE	VRECT
		
		EXIT	0
		
		CS	TFF		# SEE IF TFF IS POSMAX (I.E.- WILL NOT
		AD	POSMAX		#   INTERSECT 400,000 FT)
		CCS	A
		
		TC	STATEUP		# ALL O.K., SO SET TFF2 FLAG TO ENABLE
		OCT	10000		#   (TFF - TFFMIN) CALCULATIONS FOR SPS2
		TC	NUMCASE		#   IGNITION SEQUENCE
		
		CS	TFFNOM		# WILL NOT INTERSECT 400,000 FT, SO SET
## Page 583
		COM			#   TFF TO NOMINAL VALUE TO COMPUTE
		TS	TFF		#   TAVEGON AND TCOAST FOR A SPS2 BURN
		
		CS	TFFNOM +1
		COM
		TS	TFF +1
		
		TC	STATEDWN	# RESET TFF2 FLAG SO THAT SPS2 IGNITION IS
		OCT	10000		#   SCHEDULED A FIXED TIME AFTER AVE G. ON
		
NOMCASE		TC	INTPRET

		DSU	0		# TIME TO TURN AVE G ON =TFF-23MIN.
			TFF
			23MIN
		STORE	TAVEGON
		
		NOLOD	2		# TIME OF COAST = PIPTIME + (TFF-25MIN)
		DSU	BMN		# - TCUTOFF
		DSU	DAD
			2MIN
			SPS2NOW		# TAVEGON TOO SMALL-SCHEDULE SPS2 NOW
			TCUTOFF
			PIPTIME
		STORE	TCOAST
		
		EXIT	0
		
		CS	PIPTIME +1	# START UP FREE-FALL GYRO DRIFT COMP.
		COM
		TS	OLDBT1
		
		TC	FLAG2UP		# BEGINS WITH NEXT IDLETASK. SET DRIFTFLG
		OCT	40000
		
		TC	ENDOFJOB	# SERVICER DIES HERE AT START OF COASTPHS.
		
SPS2NOW		EXIT	0

		TC	FLAG1UP		# SET INIT FLAG TO ENABLE MANEUVER TO
		OCT	00400		#   SPS2 BURN ATTITUDE
		
		CAF	ONE
		TS	VNCNTR
		
		TC	FLAG1DWN	# REMOVE COAST FLAG TO CANCEL COLD SOAK
		OCT	40000
		
		CS	ONE		# LET ENEMA KILL COLD SOAK MANEUVER
		TC	NEWPHASE
## Page 584
		OCT	00002
		
		CS	ONE		# LET ENEMA KILL CALL FOR FDAONTSK
		TC	NEWPHASE
		OCT	00004
		
		CAF	PRIO15		# DO AN EMEMA AFTER THIS JOB
		TC	NOVAC
		CADR	ENEMA		# RESTART READACCS AND WAIT FOR TFFMIN
		
		TC	INTPRET
		
TFFTEST		TEST	1		# TEST IF TFFMIN SHOULD BE CHECKED.
		DSU	BPL		# TFF2 FLAG SET AT SPS1 CUTOFF
			TFF2FLAG
			TFFTEST1
			TFF
			TFFMIN
			TSSTEST1
		EXIT	0

TESTTFF		INHINT
		CAF	90SEC32
		TC	WAITLIST
		CADR	PLUSX2
		
		CCS	S2SWITCH	# SEE IF 2ND BURN ATTITUDE TO BE COMPUTED
		TC	SET32		# NO
		TC	SET32
		TC	+1
		TC	FLAG1UP		# SET INIT FLAG TO RE:MANEUVER TO SPS2
		OCT	00400		#   BURN ATTITUDE
		
		CAF	ONE
		TS	VGCNTR
		
SET32		TC	NEWMODE		# SET MAJOR MODE TO PRE-SPS2
		OCT	00032
		
		TC	SETBRNSW	# SET BURN TO SPS2 BACK UP SETTING
		OCT	00020
		
		CS	TIME1
		TS	TBASE4
		
		CAF	THIRTY
		TC	NEWPHASE
		OCT	00004
		
		TC	STATEDWN	# REMOVE TFF2FLAG
## Page 585
		OCT	10000
		
		TC	INTPRET
		
TFFTEST1	TEST	2		# TEST IF INTP FLAG SET
		ABS	DSU
		BMN	TEST
			INTPFLAG
			INITEST		# IT IS NOT. CONTINUE AT INITEST
			TFF		# TEST IF TFF LESS THAN 95 SECS
			DP95SEC
			SHUTDWN1	# IT IS. PREPARE TO FREE-FALL RE-ENTER
			INT1FLAG	# TEST IF FIRST INTERUPT FLAG SET
			+3		# IT IS NOT
		
		EXIT	0		# IT IS. WAIT FOR 95 SEC INTERUPT
		TC	ENDSER32
		
		NOLOD	1		# TEST IF TFF LESS THAN 200 SECS
		DSU	BPL
			DP105SEC
			INITEST		# IT IS NOT. CONTINUE
		
		EXIT	0
		TC	BANKCALL	# IT IS. BRANCH TO SHUTDOWN ROUTINES
		CADR	SHUTDOWN
		
		TC	FLAG1UP
		OCT	00100
		
		TC	SHTFLGUP
		
SHUTDWN1	EXIT	0
		TC	BANKCALL
		CADR	SHUTDOWN
		
		TC	FLAG1DWN	# REMOVE INTP FLAG (DISABLE TFF DECISIONS)
		OCT	01000
		
SHTFLGUP	TC	FLAG1UP		# SET SHTDN FLAG
		OCT	04000
		
		TC	ENDSER32



REDO5.23	CAF	ELEVEN		# RE-ESTABLISH VR, DIFFVECT IN CASE OF
		TS	MPAC		# 5.23 RESTART
		INDEX	MPAC
		CS	VR1
## Page 586
		INDEX	MPAC
		TS	VR
		CCS	MPAC
		TC	REDO5.23 +1
		
		CS	VGCNT1
		TS	VGCNTR
		CS	DVCNT1
		TS	DVCNTR
		
		TC	RE5.23



DP2SEC		DEC	0.0
2SEC		DEC	200
23MIN		2DEC	138000 B-28
2MIN		2DEC	12000 B-28
OCT77		OCT	00077
90SEC32		DEC	9000
DP105SEC	2DEC	10500
DP95SEC		2DEC	9500

## Page 587

INITEST		EXIT	0
		CS	FLAGWRD1	# TEST IF THIS IS AN INITIAL PASS
		MASK	INITMASK
		CCS	A
		TC	DVMNTEST	# IT IS NOT
		
		CS	FLAGWRD2	# TEST IF BURN IS ABORT AFTER TUMBLE ARRET
		MASK	TABTMASK
		CCS	A
		TC	INITISE		# IT IS NOT
		
		TC	NEWMODE		# SET MAJOR MODE TO POST TUMBLE RECOVERY
		OCT	00071
		
		CAF	31.8DEG		# TO REGAIN ATTITUDE AFTER TUMBLE SET AN
		TS	LOOKANG		# AVERAGE ANGLE TO HORIZON OF 31.8 DEGS.
		
INITISE		TC	INTPRET

		VMOVE	0		# DEFINES TRAJECTORY PLANE FOR YAW
			VN		#   STEERING. USED IN CALCVGB
		STORE	VIGNTION
		
		ITC	0		# BRANCH TO VG, B VECTOR COMPUTATIONS
			CALCVGB
		
		EXIT	0
		
		CCS	VGCNTR		# WAIT FOR SECOND PASS THRU CALCVGB BEFORE
		TC	+2		# COMPUTING THRUST ATTITUDE
		TC	+3
		
		TS	VGCNTR
		TC	ENDSER32
		
		TC	INTPRET
		
		ITC	0
			BURNINIT
		
		EXIT	0
		
		INHINT
		CAF	PRIO12		# ESTABLISH JOB TO COMPUTE MANEUVER TO
		TC	FINDVAC		# BURN INITIAL ATITUDE
		CADR	ATTIJOB
		
		CAF	ONE		# SET VGCNTR FOR TWO PASSES THROUGH
		TS	VGCNTR		# CALCVGB BEFORE ISSUINS STEER COMMANDS
## Page 588
		CAF	35DEG		# RESTORE ANGLE TO HORIZON TO 35 DEGS
		TS	LOOKANG
		
		TC	PHASCHNG
		OCT	00402
		
		TC	FLAG1DWN	# REMOVE INIT FLAG
		OCT	00400
		
		TC	ENDSER32
		
31.8DEG		DEC	0.088333	# SCALED AT 1 REV
35DEG		DEC	0.097222
INITMASK	EQUALS	BIT9

VRFAIL		EXIT	0		# EXIT HERE IF FAILURE TO COMPUTE ABORT VR

		CCS	VGCNTR		# TEST IF THIS IS LAST PASS
		TC	+2
		TC	ENDSHUT		# IT IS. DO SHUTDOWN
		
		TS	VGCNTR		# WAIT FOR MORE
		TC	ENDSER32
		
DVMNTEST	CS	FLAGWRD1	# TEST IF DV MONITOR IS ENABLED
		MASK	DVMONMSK
		CCS	A
		TC	ENDSER32	# IT IS NOT
		
		TC	INTPRET
		
		ABVAL	2		# TEST IF DELV MAG. EXCEEDS DVMIN
		DSU	BMN
		EXIT
			DELV
			DVMIN
			NODELTAV	# IT DOES NOT. START DV MONITOR

		CS	ONE		# IT DOES. (DVCNTR NORMALLY NEGATIVE)
		TS	DVCNTR
		
		TC	BANKCALL
		CADR	STRTEST
		
NODELTAV	EXIT	0
		CCS	DVCNTR
		
		TC	DVALARM		# AFTER FIRST TIME SET ALARM
		TC	SHUTDWN3	# 5 PASSES UP. PREPARE FOR RE-ENTRY
## Page 589
		CAF	NINE		# FIRST TIME SET DVCNTR FOR 10 PASSES
		TS	DVCNTR
		
		TC	ENDSER32
		
DVALARM		TC	ALARM
		OCT	01402
		
		CCS	DVCNTR
		TS	DVCNTR
		
		TC	ENDSER32
		
SHUTDWN3	CS	FLAGWRD2
		MASK	SPS1MASK
		CCS	A
		TC	SHUTDWN4	# SHUT DOWN IF NOT DOING SPS1 BURN
		
		INHINT			# CALL ON ENGINE-OFF IMMEDIATELY IF SPS1
		CAF	ONE
		TC	WAITLIST
		CADR	ENGINOFF
		RELINT
		
		TC	FLAG1DWN	# REMOVE STEER FLAG
		OCT	00010
		
		TC	PHASCHNG
		OCT	04104
		
		TC	ENDSER32
		
SHUTDWN4	TC	FLAG1UP		# ENABLE FREE-FALL INTERRUPT
		OCT	01000
		
ENDSHUT		TC	BANKCALL
		CADR	SHUTDOWN
		
ENDSER32	TC	BANKCALL	# EXIT FROM SERVICER FROM BANK 32
		CADR	ENDSERV
		
		SETLOC	66000
DVMONMSK	EQUALS	BIT5
DVMIN		2DEC	0.000318008	# 2FT/S SCALED AT 19.16928 M/CS

STRTEST		CS	FLAGWRD1	# TEST IF STEER FLAG SET
		MASK	BIT4
		CCS	A
		TC	ENDSERV		# IT IS NOT
## Page 590
		TC	INTPRET
		
		ITC	0
			CALCVGB
		
		EXIT	0
		
		TC	PHASCHNG
		OCT	00505

REDO5.5		CCS	VGCNTR
		TC	+2		# BEFORE TESTING VG AND GENERATING STEERIN
		TC	JUMP10		# COMMANDS
		
		TS	ERRORSUM	# ZERO STEER ERROR SUM
		TS	ERRORSUM +1
		TS	ERRORSUM +2
		TS	ERRORSUM +3
		TS	ERRORSUM +4
		TS	ERRORSUM +5
		
		CAF	MDTINIT
		TS	MDT
		TS	MDT +1
		
		CCS	VGCNTR
		TS	VGCNTR
		
		TC	ENDSERV
		
MDTINIT		DEC	0.00381		# 16FT/S/S FOR 2.5 SECS AT 2(+5)M/CS

JUMP10		TC	FLAG2DWN	# REMOVE CALC FLAG (KILLS ATTITUDE MAN-
		OCT	02000		# EUVER IF STILL ACTIVE)
		
		TC	INTPRET
		
		VXSC	1
		BVSU	UNIT
			DELV
			KPIP
			CBDT
		STORE	UNITMDT
		
		NOLOD	1		# TEST IF VG INCREASING WITH THRUST
		DOT	BPL
			VG
			VGALARM		# IT IS. BRANCH TO CUT ENGINE AND WAIT
		STORE	26D		# VG ACTUAL
## Page 591
		DAD	0		# SUM TWO INTERVALS OF MDT
			30D
			MDT

JUMP9		DMP	3		# RESCALE VG ACTUAL TO 2(+5)M/CS
		TSLT	BOV
		DDV	BOV		# IF NO OVER FLOW ON DIVISION, LESS THAN
		DMP	ITC		# 2 INTERVALS OF VG LEFT
			26D
			0.995
			3
			STEERLAW
			-
			STEERLAW
			DELTAT
			SETTGO		# BRANCH TO SET TIME-TO-GO TO CUT-OFF

STEERLAW	DMOVE	0		# SAVE NEW VALUE OF MDT
			30D
		STORE	MDT
		
		DMP	0
			K1STEER		# =(0.815...)(STEER GAIN)
			DELTAT
		
		ABVAL	3		# STEERING CROSS PRODUCT COMPUTED HERE
		TSLC	BDDV
		VXSC	VXV
		VSLT*
			VG
			X2
			-
			VG
			UNITMDT
			0,2
		STORE	STEERROR	# FIRST TERM IN STEERLAW OUTPUT. SCALED
					# AT ONE REVOLUTION
		NOLOD	1		# INCREMENT SUM OF STEER ERRORS
		VXSC	VAD
			K2STEER		# =(INTEGRATOR GAIN)/(STEER GAIN)
			ERRORSUM
		
		NOLOD	2		# TEST IF MAGNITUDE OF INTEGRATED STEER
		ABVAL	DSU		# ERROR EXCEEDS MAX ALLOWABLE
		BPL
			ERRORMAX
			SUMPOINT
		
		VMOVE	0
		STORE	ERRORSUM	# STORE NEW STEER ERROR SUM
## Page 592

SUMPOINT	VAD	1		# SUM ERROR AND INTEGRATED ERROR TERMS
		RTB	ITC
			STEERROR
			ERRORSUM
			FRESHPD
			CDUDRIVE	# BRANCH WITH TOTAL STEERLAW OUTPUT IN VAC
					# SCALED AT ONE REVOLUTION
STREXIT		VSLT	1
		COMP	EXIT		# RESCALE VG TO 2(+5)M/CS FOR DISPLAY
			VG
			2
		
		TC	GRABDSP		# TRY TO GRAB DISPLAY
		TC	NODISP		# ALREADY GRABBED. SKIP VG DISPLAY
		
		INDEX	FIXLOC		# LOAD UPPER REGISTERS OF VG INTO DSPTEM1
		CS	VAC
		TS	DSPTEM1
		
		INDEX	FIXLOC
		CS	VAC +2
		TS	DSPTEM1 +1

		INDEX	FIXLOC
		CS	VAC +4
		TS	DSPTEM1 +2
		
		CAF	V06N40
		TC	NVSUB
		TC	RELDSPON
		
		TC	FREEDSP
		
NODISP		TC	ENDSERV

V06N40		OCT	00640		# VERB 06 NOUN 40
1.523		2DEC	1.523 B-3
0.995		2DEC	0.995
K1STEER		2DEC	0.101859164	# (STEER GAIN =1/8)
K2STEER		2DEC	0.08		# (INTEGRATOR GAIN =0.01)
ERRORMAX	2DEC	0.001388888	# 1 DEGREE SCALED AT 2 REVS

SETTGO		NOLOD	2		# COME HERE TO SET ENGINE-OFF CALL
		TSRT	COMP
		TEST	EXIT
			4		# C(MPAC) = TIME-TO-CUTOFF SINCE PIPTIME
## Page 593
			STEERFLG	# SCALED AT 2(+14) CS
			STREXIT
		
		XCH	MPAC
		TS	LONGTIME	# SAVE MPAC  (USED IN RESTARTS)
		
REDO4.1		INHINT
		CS	TIME1
		TS	TBASE4
		AD	PIPTIME +1
		CCS	A
		AD	BIT15
		TC	+3
		AD	ONE
		COM
		
		AD	LONGTIME	# (TEMP FOR MPAC)
		AD	TDECAY		# EFFECTIVE THRUST DECAY TIME
		TS	LONGTIME +1
		CCS	A		# TEST FOR - OR 0 WAITLIST CALLS
		TC	+3
		TC	+2
		CAF	ZERO
		AD	ONE
		TC	WAITLIST
		CADR	ENGINOFF
		
		TC	PHASCHNG
		OCT	00104
		
		TC	FLAG1DWN	# REMOVE STEER FLAG
		OCT	00010
		
		TC	PHASCHNG
		OCT	00204
		
		TC	ENDSERV
		
VGALARM		EXIT	0
		TC	ALARM
		OCT	01401
		
		TC	BANKCALL
		CADR	SHUTDWN3
		
ENDSERV		CCS	DELTAT +1	# IF BIT1 PRESENT IN DELTAT +1, SET DELTAT
		CAF	HALFSEC		# 1/PIPADT TO 2.5SECS (FOR ABORT STEERING)
		AD	TWOSEC
		TS	DELTAT
		DOUBLE
## Page 594
		TS	1/PIPADT
		
		TC	PHASCHNG
		OCT	00105
		
		TC	ENDOFJOB
		
HALFSEC		DEC	50 B-9
TWOSEC		DEC	200 B-9
ALLABORT	OCT	7

## Page 595

BURNINIT	AXC,1	2		# C(X1)= 0  (TABT,ABRT,SPS1)
		ITA	TEST		#      =-2  (SPS2)
		AXC,1
			0
			S2
			SPS2FLAG
			+2
			2
		
		ITC	0		# COMPUTE DESIRED THRUST DIRECTION
			CALCXSC
		
		RTB	1		# SET UP CG ROTATION MATRIX IN PD
		SMOVE*
			ZEROVAC
			CGZ,1
		STORE	6
		
		NOLOD	1
		COMP	AST,1
			6
		STORE	2
		
		SMOVE*	0
			CGY,1
		STORE	4
		
		NOLOD	1
		COMP	AXT,1
			18D
		STORE	12D
		
REPEAT2		VMOVE*	2		# COMPUTE DESIRED SPACECRAFT ATTITUDE
		VXM	VAD*		# MATRIX FROM DESIRED THRUST ATT. MATRIX
		UNIT
			18D,1
			XSC
			XSC +18D,1
		STORE	XSCD +18D,1
		
		TIX,1	1
		ITCI
			REPEAT2
			S2
## Page 596

ROLLJOB		TC	INTPRET

		AXT,1	1		# GET SIN,COS OF THETAD,+1,+2
		AST,2	ITC
			6
			ROLLEXIT
			THETRIG
		
		ITC	0		# COMPUTE NAV. BASE COORDINATES
			CALCSMNB
		
		VXSC	0
			XNB
			COS33
		
		VXSC	2
		VAD	TEST
		COMP
			ZNB
			SIN33
			-
			SPS2FLAG	# IF SPS2, INVERT XSC
			HEADWN1
		STORE	22D

HEADWN1		NOLOD	3
		VXV	UNIT		# =KR(TVC)(UNIT(XSC*RN)*YSC), WHERE
		VXV	VXSC		#	DT(MAX) = 10 SECS,
		VSLT	ITC		#	MAX ROLL GAIN = 1.0
			RN
			YNB		# ( =YSC)
			KR(TVC)		# TVC ROLL CONTROL GAIN
			3
			CDUDRVE2	# SUBENTRY OF CDUDRIVE

ROLLEXIT	EXIT	0

		CS	FLAGWRD1	# TEST IF STEER FLAG SET BEFORE SETTING
		MASK	BIT4		# BURN MAJOR MODE
		CCS	A
		TC	ENDOFJOB
		
		CAF	BIT5		# TEST IF BURN SWITCH IS SET TO SPS2
		MASK	FLAGWRD2
		CCS	A
		TC	SPS2MODE	# IT IS
		
		CS	FLAGWRD2	# TEST IF BURN IS SPS1
		MASK	BIT4
		CCS	A
## Page 597
		TC	ENDOFJOB	# IT IS NOT
		
		TC	NEWMODE		# SET MAJOR MODE TO SPS1
		OCT	00041
		TC	ENDOFJOB
		
SPS2MODE	TC	NEWMODE		# SET MAJOR MODE TO SPS2
		OCT	00042
		
		TC	ENDOFJOB
		
KR(TVC)		2DEC	0.0204		# ROLL GAIN =0.05, DT =5.0 SECS

## Page 598

# THIS ROUTINE CONTROLS THE USE OF CALCMANU IN COMPUTING, TIMING AND PERFORMING THE SEQUENCE OF MANEUVERS DURING
# A LARGE ATTITUDE MANEUVER. FLIGHT 501 INVOLVES SUCH A MANEUVER WHEN ORIENTING TO
#	1.  ABORT BURN INITIAL ATTITUDE AFTER A TUMBLE ARREST
#	2.  NOMINAL FIRST BURN INITIAL ATTITUDE
#	3.  LOCAL VERTICAL AFTER NOMINAL FIRST BURN
#	4.  NOMINAL SECOND BURN INITIAL ATTITUDE
#	5.  SM/CM SEPARATION ATTITUDE
#	6.  CM PRE-ENTRY ATTITUDE



ATTIJOB		TC	BANKCALL
		CADR	IMUATTC
		
		TC	SETHETAD
		
		TC	BANKCALL
		CADR	IMUSTALL
		TC	CURTAINS
		
		TC	INTPRET
		
ATTIJOB1	ITC	0
			GETMANU
		
		EXIT	0
		
		INHINT
		CAF	0.01SEC
		TC	WAITLIST
		CADR	DOMANU
		
		TC	ENDOFJOB



ATTIJOB2	TC	INTPRET

		ITC	0
			GETMANU
		
		EXIT	0
		TC	ENDOFJOB



SNAPOUT		NOLOD	0
		STORE	THETAD
		
		TEST	1		# TEST IF SHTDN FLAG SET (I.E. HAS FREE-
## Page 599
		TEST	EXIT		# FALL INTERRUPT OCCURRED)
			SHTDNFLG
			JUMP7
			CDUXFLAG	# TEST IF CDUXFLAG SET (I.E. HAS CM/SM
			ENDMANU		# SEPARATION OCCURRED)
		
		TC	FLAG1UP		# SET ENTRY FLAG
		OCT	00004
		
		CS	ONE
		TC	NEWPHASE
		OCT	00003
		
		TC	ENDOFJOB
		
JUMP7		TEST	1
		EXIT
			COASTFLG
			JUMP6
		
		TC	FLAG1UP		# SET SOAK FLAG FOR BEGINNING OF CONTROL
		OCT	10000		#   AT COLD SOAK ATTITUDE
		
		TC	NEWMODE
		OCT	00022
		
		TC	ENDMANU +1
		
JUMP6		TEST	0
			TABTFLAG
			ENDMANU
		
		EXIT	0
		
		INHINT
		CAF	0.01SEC
		TC	WAITLIST
		CADR	ATTCNOFF
		
		CAF	TWO		# SET VGCNTR FOR THREE PASSES THROUGH
		TS	VGCNTR		# CALCVGB BEFORE STARTING ABORT STEERING
		
		TC	ENDMANU +1
		
ENDMANU		EXIT	0

		CS	ONE
		TC	NEWPHASE
		OCT	2
## Page 600
		TC	ENDOFJOB

## Page 601

GETMANU		ITA	1
		ITC
			EXITCAD1
			CALCMANU
		
		TEST	0
			CALCFLAG
			SNAPOUT
		
		AXC,1	2
		TEST	AXC,1
		TEST	AXC,1
			Q
			ROLLFLAG
			SETDTH
			2
			CDUXFLAG
			SETDTH
			4

SETDTH		DMOVE*	0
			DTH,1
		STORE	DTHETA
		
		ITCI	0
			EXITCAD1



0.01SEC		EQUALS	BIT1

## Page 602

DOMANU		TC	FLAG2UP		# SET DOMANU FLAG
DOMANMSK	OCT	01000

DOMANU1		CS	FLAGWRD2	# KILL DOMANU IF CALC FLAG NOT SET
		MASK	BIT11		# (CALCMASK)
		CCS	A
		TC	DOMANOFF
		
		CAF	DOMANMSK	# TEST IF DOMAN FLAG SET
		MASK	FLAGWRD2
		CCS	A
		TC	SETMANU		# IT IS
		
		CAF	TPAD +1		# IT IS NOT. START NEXT MANEUVER IN TPAD
		TC	WAITLIST	# SECS
		CADR	DOMANU
		
		TC	TASKOVER
		
SETMANU		CAF	PRIO23		# ESTABLISH MANUJOB
		TC	FINDVAC
		CADR	MANUJOB
		
		CAF	0.5SEC		# RECALL DOMANU1 IN 0.5 SECS
		TC	WAITLIST
		CADR	DOMANU1
		
		TC	TASKOVER
		
DOMANOFF	TC	FLAG2DWN	# REMOVE DOMANU FLAG
		OCT	01000
		
		TC	TASKOVER



TPAD		DEC	0.0
5SEC		DEC	500
0.5SEC		DEC	50



MANUJOB		TC	INTPRET

		DSU	1		# TEST IF THETAMAN LESS THAN DTHETA.
		BPL	COMP
			DTHETA
			THETAMAN
			JUMP4		# IT IS. STORE REMAINING THETAMAN
		STORE	THETAMAN
## Page 603
		ITC	0
			DRIVECDU
		
JUMP4		DMOVE	0		# STORE REMAINING THETAMAN IN DTHETA
			THETAMAN
		STORE	DTHETA
		
		EXIT	0
		
		TC	FLAG2DWN	# REMOVE DOMANU FLAG
		OCT	01000
		
		TC	INTPRET
		
DRIVECDU	VXSC	1		# FORM INCREMENTAL MANEUVER VECTOR
		VSLT	ITC
			WC
			DTHETA
			1
			CDUDRIVE
		
		TEST	0		# TEST IF DOMAN FLAG SET
			DOMANFLG
			NEXTMAN		# IT IS NOT. GET NEXT MANEUVER
		
		EXIT	0
		TC	ENDOFJOB
		
NEXTMAN		EXIT	0

		INHINT
		CAF	PRIO12		# ESTABLISH ATTIJOB2 TO COMPUTE NEXT MAN.
		TC	FINDVAC
		CADR	ATTIJOB2
		
		TC	ENDOFJOB

## Page 604

SOAKINIT	TC	NEWMODE		# SET MAJOR MODE TO MANEUVER TO COLDSOAK
		OCT	00021
		
		TC	INTPRET
		
		SMOVE	0
			ANGLEZ		# COLDSOAK -  Z GIMBAL ANGLE
		
		SMOVE	0
			ANGLEY		# COLDSOAK -  Y GIMBAL ANGLE
		
		SMOVE	1
		VDEF	COMP
			ANGLEX		# COLDSOAK -  X GIMBAL ANGLE
		STORE	CDUTEMP
		
		AXT,1	1
		ITC
			6
			SINCOS
		
		ITC	0
			CALCSMNB	# NAV BASE IN SM COORDINATES
		
		ITC	0
			CALCNBSC	# SC IN SM COORDINATES
		
		VMOVE	0
			XSC
		STORE	XSCD
		
		VMOVE	0
			YSC
		STORE	YSCD
		
		VMOVE	0
			ZSC
		STORE	ZSCD
		
		ITC	0		# BRANCH TO DO MANEUVER
			ATTIJOB1

## Page 605

SOAKTASK	CS	ZERO		# COME HERE FIRST TIME ONLY. CLEAR OUT
		TS	DELV		# DELV FOR FREE-FALL COMPUTATIONS
		TS	DELV +1
		TS	DELV +2
		TS	DELV +3
		TS	DELV +4
		TS	DELV +5

SOAKTSK1	CAF	BIT15		# TEST IF COAST FLAG SET
		MASK	FLAGWRD1
		CCS	A
		TC	CCSHOLE
		TC	TASKOVER
		
		CAF	SEVEN
		TC	NEWPHASE
		OCT	0005
		
REDO5.7		CS	TIME1
		TS	TBASE5
		
		CAF	EIGHT
		TC	NEWPHASE
		OCT	00005
		
		CAF	2SEC33
		TC	WAITLIST
		CADR	SOAKTSK1
		
		CAF	PRIO13
		TC	FINDVAC
		CADR	SOAKJOB
		
		TC	TASKOVER
		
2SEC33		DEC	200

## Page 606

SOAKJOB		CS	FLAGWRD1	# TEST SOAKFLAG
		MASK	BIT13
		CCS	A
		TC	SOAKEXIT	# SOAKFLAG OFF
		TC	INTPRET		#  SOAKFLAG ON
		
		DMOVE	0		# SET DELTAT TO 4 SECS FOR ORBITAL INT.
			DT4SEC
		STORE	DELTAT
		
		VMOVE	0		# SAVE VRECT AND RRECT IN CASE OF RESTARTS
			RRECT
		STORE	RRECCMEM
		
		VMOVE	0
			VRECT
		STORE	VRECCMEM
		
		EXIT	0
		TC	PHASCHNG
		OCT	01205
		
REDO5.10	TC	FLAG1DWN	# REMOVE COAST, SOAK FLAGS
		OCT	50000
		
		TC	INTPRET
		
		VMOVE	0		# RESTORE RRECT AND VRECT FROM CMEMORY.
			RRECCMEM
		STORE	RRECT
		
		VMOVE	0
			VRECCMEM
		STORE	VRECT
		
		ITC	0		# BRANCH TO DO ORBITAL INTEGRATION
			AVETOMD1
		
		VMOVE	1
		VSLT
			RIG-4SEC
			RSCALE -15D
		STORE	RN		# SET RN TO 4 SECS BEFORE IGNITION
		
		RTB	1
		ITC
			FRESHPD
			CALCGRAV
		
		VMOVE	0
## Page 607
			VIGNTION
		STORE	VN		# SET VN AT IGNITION
		
		AXT,1	1
		SXA,1	ITC
			501SPS2
			VRCADR
			CALCVGB
		
		VMOVE	1
		VSLT
			RIGNTION
			RSCALE -15D
		STORE	RN		# SET RN AT IGNITION
		
		ITC	0
			CALCGRAV
		
		ITC	0
			CALCVGB		# GET VR AT IGNITION. COMPUTE CBDT
		
		ITC	0
			BURNINIT	# INITIALISE BURN
		
		DMOVE	0
			ST2SEC
		STORE	DELTAT		# RESTORE DELTAT TO 2 SECS FOR SPS2
		
		VMOVE	0
			VAVEGON
		STORE	VN		# INITIALISE CALCRVG FOR TURN-ON
		
		VMOVE	1
		VSLT
			RAVEGON
			RSCALE -15D
		STORE	RN
		
		ITC	0
			CALCGRAV
		
		EXIT	0
		
		CAF	ONE		# SET VGCNTR FOR TWO PASSES THRU CALCVGB
		TS	VGCNTR		# BEFORE SPS2 STEERING
		
		TC	NEWMODE		# SET MAJOR MODE TO READY FOR R,V,T UPDATE
		OCT	00024
		
		TC	PHASCHNG	# CHANGE PHASE TO 5.20 TO ENABLE V76 RST.
## Page 608
		OCT	02405
		
		TC	ENDOFJOB
		
SOAKEXIT	TC	PHASCHNG
		OCT	01305
		
		TC	ENDOFJOB
		
DT2SEC		2DEC	200 B-9
DT4SEC		2DEC	400 B-9
		BANK	24

## Page 609

# UPTASK AND UPJOB OCCUR 120 SECS BEFORE PLUSX2 AND INCORPORATE STATE VECTOR UPDATES VIA VERB 76

UPTASK		CAF	10SEC24		# SCHEDULE FDAI ALIGN OFF IN 10 SECS
		TC	WAITLIST
		CADR	FDAIOFF2
		
		TC	RELAYON		# SET SCS FDAI ALIGN DISCRETE (C31)
		OCT	40400
		
		CAF	PRIO6		# ESTABLISH UPJOB
		TC	FINDVAC
		CADR	UPJOB
		
		CAF	SEVEN
		TC	NEWPHASE
		OCT	00004
		
		CS	TIME1
		TS	TBAASE4
		
		CS	ONE		# REMOVE UPDATE RESTART CAPABILITY
		TC	NEWPHASE
		OCT	5
		
		CAF	EIGHT
		TC	NEWPHASE
		OCT	00004
		
		TC	TASKOVER
		
UPJOB		TC	NEWMODE		# REVERT TO ATTITUDE HOLD WITH NO V76.
		OCT	22

		CAF	LDNLST1		# REVERT BACK TO DOWNLIST 1.
		TS	DNLSTADR
		
		TC	INTPRET
		
		TEST	2		# NO FURTHER ACTION IF NO V76 COMPLETED.
		DAD	DAD		# IF SO, FORM DT FOR FINAL INTEGRATION.
		DSU
			UPDATFLG
			NOSTATE
			TCUTOFF
			TCOAST
			DP120SEC
			STBUFF +12D
		STORE	TAVEGON
		
		MXV	1
## Page 610
		VSLT
			RRECT
			REFSMMAT
			1		# THIS ASSUMES THAT UPDATE SCALED 2(26)M
		STORE	RRECCMM
		
		MXV	1
		VSLT
			VRECT
			REFSMMAT
			1		# THIS ASSUMES THAT UPDATE SCALED 2(7)M/CS
		STORE	VRECCMEM
		
		EXIT	0
		TC	PHASCHNG
		OCT	03504
		
REDO4.29	TC	INTPRET
		VMOVE	0
			RRECCMEM
		STORE	RRECT
		
		VMOVE	0
			VRECCMEM
		STORE	VRECT
		
		ITC	0
			AVETOMD2
		
		VMOVE	0		# LEAVE RAVEGON, VAVEGON IN RN, VN.
			VAVEGON
		STORE	VN
		
		VSLT	0
			RAVEGON
			RSCALE -15D
		STORE	RN
		
		RTB	1
		ITC
			FRESHPD
			CALCGRAV
		
NOSTATE		ITC	0		# GO GET TFF
			CALCTFF
		
		DSU	1		# SEE IF TFF IS TOO HIGH
		BPL	EXIT
			TFF
			TFFLIMIT
## Page 611
			TFF2DOWN	# YES

SETMM23		TC	NEWMODE		# HOLD ATTITUDE AFTER ORBITAL INTEGRATION
		OCT	23
		
		TC	PHASCHNG
		OCT	01104
		
REDO4.9		TC	JAMTERM		# FLUSH OUT V76 IF STILL IN PINBALL



TFF2DOWN	EXIT	0
		TC	STATEDWN	# RESET TFF2 FLAG
		OCT	10000
		TC	SETMM23



FDAIOFF2	TC	RELAYOFF	# REMOVE SCS FDAI ALIGN DISCRETE (C31)
		OCT	40400
		
		CAF	105SEC
		TC	WAITLIST
		CADR	PREAVGON
		
		TC	TASKOVER



PREAVGON	CAF	5SEC24
		TC	WAITLIST
		CADR	AVGON
		
		TC	RELAYOFF	# BAK-UP FDAI ALIGN OFF IN CASE OF
		OCT	40400		#   RESTARTS
		
		TC	FLAG1DWN	# REMOVE UPDAT FLAG TO KILL ORB. INTEGR.
		OCT	20000
		
		CAF	TWENTY7
		TC	NEWPHASE
		OCT	4
		
		TC	TASKOVER
		
DP120SEC	2DEC	12000
10SEC24		DEC	1000
105SEC		DEC	10500
## Page 612
5SEC24		DEC	500
TFFLIMIT	2DEC	.9		# JUST SO ITS HIGH

## Page 613

# SHUTDOWN IS A CLOSED SUBROUTINE WHICH IS ENTERED PRIOR TO CM/SM SEPARATION. ITS PURPOSE IS TO CLOSE OUT ALL SCS
# FUNCTIONS NOT CONCERNED WITH SEPARATION AND ENTRY, AND TO INITIATE THOSE THAT ARE

		BANK	33
		
SHUTDOWN	INHINT
		CAF	PRIO27		# ESTABLISH HIGH PRIO JOB TO DO SHUTDOWN
		TC	NOVAC
		CADR	ENEMA		# CLEANS OUT EXEC AND WAITLIST.
		RELINT
		
		CAF	ONE		# EFFECTIVELY STOP ANY WAITLIST ACTIVITY
		TS	TIME3
		
		CS	ONE
		TC	NEWPHASE
		OCT	00004
		
		CS	ONE
		TC	NEWPHASE
		OCT	00002
		
		CAF	TEN
		TC	NEWPHASE
		OCT	00003
		
		TC	SWRETURN	# (LOCATION OF TC Q)



SHUTJOB		INHINT
		CS	BIT13		# SHUT OFF ENGINE BIT
		MASK	OUT1
		TS	OUT1
		
		TC	RELAYOFF	# REMOVE SCS +X TRANS DISCRETE
		OCT	40020
		
		TC	FLAG1DWN	# REMOVE DVMON, STEER, INIT FLAGS
		OCT	00430
		
		TC	BANKCALL	# SET IMUCDU TO ATT. CONTROL (MAY BE RE-
		CADR	IMUATTC		# DUNDANT CALL)
		
		TC	SETHETAD	# FORCE THETAD, +1, +2 TO READ CDUX,Y,Z
		
		CAF	ALLABORT	# TEST IF ANY ABORT BURN SET
		MASK	FLAGWRD2
## Page 614
		CCS	A
		TC	+3		# IT IS
		
		TC	SETBRNSW	# IT IS NOT. SET BURN TO LAST (SPS4)
		OCT	00100
		
		TC	BANKCALL	# WAIT FOR MODE SWITCH TO COMPLETE
		CADR	IMUSTALL
		TC	CURTAINS	# CATCH-ALL FOR MODE SWITCH FAILURES
		
		CS	TIME1
		TS	TBASE3
		
		CAF	BIT10		# TEST IF INTP FLAG SET (I.E. HAS 95 SEC
		MASK	FLAGWRD1	# INTERRUPT OCCURRED)
		CCS	A
		TC	TESTGMP		# IT HAS NOT
		
		CAF	BIT7		# TEST IF INT1 FLAG SET (I.E. HAS 200 SEC
		MASK	FLAGWRD1	# INTEREUPT OCCURRED)
		CCS	A
		TC	SHUTJOB1	# IT HAS
		
TESTGMP		CAF	BIT8		# TEST IF SCS GMP DISCRETE SET
		MASK	DSPTAB +13D
		CCS	A
		TC	GMPOFF1		# IF IT IS, TURN IT OFF
		
		CAF	BIT2		# TEST IF DV MODE SET
		MASK	DSPTAB +13D
		CCS	A
		TC	DVMODOF1	# IF IT IS, TURN IT OFF
		
SHUTJOB1	CS	FLAGWRD1	# TEST IF SHUTDN FLAG SET
		MASK	BIT12
		CCS	A
		TC	SETATTC		# IT IS NOT. SHUTDOWN NOT DUE TO TFF
		
		CAF	BIT10		# TEST IF THIS IS 200 OR 95 SEC INTERRUPT
		MASK	FLAGWRD1	# (INTP FLAG)
		CCS	A
		TC	SETSEP		# 200 SEC INTERRUPT
		
KILLMANU	TC	FLAG2DWN	# REMOVE CALC FLAG (KILL ANY MANEUVER)
		OCT	02000
		
		INHINT			# ALLOW 5 SECS FOR CSM TO SETTLE FROM ANY
		CAF	5SEC		# ATTITUDE MANEUVER BEFORE SEPARATING
		TC	WAITLIST
		CADR	CDUXTASK
## Page 615
		TC	PHASCHNG
		OCT	01303
		
		TC	ENDOFJOB
		
GMPOFF1		INHINT
		CAF	2SEC33		# CALL FOR SCS GMP OFF IN 2 SECS
		TC	WAITLIST
		CADR	GMPOFF2
		
		TC	PHASCHNG
		OCT	02703
		
		TC	ENDOFJOB
		
DVMODOF1	INHINT
		CAF	3.5SEC33	# CALL FOR DV MODE OFF IN 3.5 SECS
		TC	WAITLIST
		CADR	DVMODOF2
		RELINT
		
		TC	PHASCHNG
		OCT	03003
		
		TC	ENDOFJOB
		
GMPOFF2		TC	RELAYOFF	# REMOVE SCS GMP DISCRETE
		OCT	40200
		
		CAF	3.5SEC33	# CALL FOR DV MODE OFF IN 3.5 SECS
		TC	WAITLIST
		CADR	DVMODOF2
		
		CAF	TWENTY5
		TC	NEWPHASE
		OCT	3
		
		TC	TASKOVER
		
DVMODOF2	TC	RELAYOFF	# REMOVE SCS DV MODE DISCRETE
		OCT	40002
		
		CAF	0.25S33		# CALL FOR SCS ATT. CONTROL IN U/4 SEC
		TC	WAITLIST
		CADR	SHUTASK
		
		TC	TASKOVER
		
SHUTASK		CAF	PRIO27		# ESTABLISH JOB TO RESUME SHUTDOWN PROCESS
		TC	NOVAC
## Page 616
		CADR	SHUTJOB1
		
		TC	TASKOVER
		
SETSEP		INHINT
		CAF	PRIO12
		TC	FINDVAC		# CM/SM SEPARATION ATTITUDE
		CADR	SEPMANU
		
SETATTC		TC	RELAYON		# SET SCS ATT. CONTROL DISCRETE (C23)
		OCT	40001
		
		TC	ENDOFJOB
		
0.25S33		DEC	25
3.5SEC33	DEC	350
5SEC33		DEC	500
7SEC33		DEC	700

## Page 617

SEPMANU		TC	NEWMODE		# SET MAJOR MODE TO SEPARATION MANEUVER
		OCT	00061
		
		TC	INTPRET
		
		UNIT	1		# COMPUTE DESIRED S/C ORIENTATION FOR
		VXSC	COMP		# CM/SM SEPARATION
			VN
			COS60
		
		NOLOD	1
		VXV	UNIT
			RN
		STORE	YSCD		# YSCD IS ALONG (RN*VN)
		
		NOLOD	3
		VXV	UNIT
		VXSC	VAD
		COMP
			VN
			SIN60
		STORE	XSCD		# XSCD IS 60 DEG ABOVE VELOCITY VECTOR
		
		NOLOD	1
		VXV	UNIT
			YSCD
		STORE	ZSCD
		
		ITC	0		# BRANCH TO PERFORM MANEUVER TO THE
			ATTIJOB1	# SEPARATION ATTITUDE

SIN60		2DEC	0.86603
COS60		2DEC	0.5

## Page 618

CDUXTASK	CAF	5SEC		# ALLOW 5 SECS FOR CDUX RESOLVER SCALE
		TC	WAITLIST	# CHANGE
		CADR	CM/SMTSK
		
		CAF	PRIO20
		TC	FINDVAC
		CADR	CDUXJOB
		
		TC	RELAYOFF	# SET SCS TO MONITOR MODE
		OCT	40007
		
		CAF	TWELVE
		TC	NEWPHASE
		OCT	00003
		
		TC	TASKOVER



CDUXJOB		CS	THETAD
		COM
		TS	CDUTEMP
		
		CCS	CDUTEMP		# GET MAGNITUDE OF THETAD
		AD	ONE
		TC	+2
		AD	ONE
		TS	MPAC		# AND SAVE IT
		
		EXTEND			# FIND NEAREST INTEGER MULTIPLE OF 1/16
		MP	15/16TH
		AD	BIT11
		MASK	HIGH4
		XCH	MPAC		# AND SAVE IT
		
		EXTEND			# SHIFT ORIGINAL THETAD RIGHT 4 PLACES
		MP	BIT11
		AD	MPAC		# AND ADD INTEGER MULTIPLE
		INHINT
		TS	THETAD
		
		CCS	CDUTEMP		# ATTACH SIGN OF ORIGINAL THETAD
		XCH	MPAC		# MPAC HAS POSITIVE CDUBIAS
		TC	+4
		CS	THETAD
		TS	THETAD
		
		CS	MPAC		# COMPLEMENT INTEGER MULTIPLE
		TS	K1ROLL		# SCALED AT 1/2 REV FOR ENTRY
		RELINT
## Page 619
		TC	PHASCHNG
		OCT	01503
		
REDO3.13	TC	FLAG2UP		# SET CDUX FLAG
		OCT	20000
		
		TC	BANKCALL	# CHANGE IMUCDU MODE TO RE-ENTRY
		CADR	IMUREENT
		
		TC	BANKCALL	# WAIT FOR COMPLETION OF MODE SWITCH
		CADR	IMUSTALL
		TC	CURTAINS	# CATCH-ALL FOR MODE SWITCH FAILURES
		
		TC	PHASCHNG
		OCT	01603
		
		TC	ENDOFJOB



CM/SMTSK	TC	RELAYON		# SET SCS ENTRY MODE AND CM/SM SEPARATION
		OCT	40014		# DISCRETES
		
		CAF	FIFTN
		TC	NEWPHASE
		OCT	00003
		
		CAF	5SEC		# SET CALL TO START PRE-ENTRY ATTITUDE
		TC	WAITLIST	# MANEUVER IN 5 SECS
		CADR	ENTATASK
		
		TC	TASKOVER
		
15/16TH		OCT	36000
HIGH4		OCT	74000

## Page 620

ENTATASK	CAF	PRIO12
		TC	FINDVAC
		CADR	ENTAJOB
		
		TC	TASKOVER



ENTAJOB		TC	NEWMODE		# SET MAJOR MODE TO PRE-ENTRY MANEUVER
		OCT	00062
		
		CAF	ZERO
		TS	ROLLC		# ROLLC = +0
		TS	ROLLC +1
		
		TC	INTPRET
		
GOGETUNB	ITC	0		# COMPUTE DESIRED NAV BASE COORDS.
			GETUNB
		
		ITC	0		# GET DESIRED S/C COORSD
			CALCNBSC
		
		VMOVE	0		# TRANSFER DESIRED S/C UNIT VECTORS
			XSC
		STORE	XSCD
		
		VMOVE	0
			YSC
		STORE	YSCD
		
		VMOVE	0
			ZSC
		STORE	ZSCD
		
		ITC	0		# BRANCH TO PERFORM MANEUVER TO PRE-ENTRY
			ATTIJOB1	# ATTITUDE

ABORT33		OCT	00007		# (OR OF ARRST,TABT,ABRT)



		BANK	24

AVGON		CAF	PIPCAD24	# CLEAR AND EXCHANGE PIPAS TO SAVE DELV
		TC	ISWCALL		# ACCUMULATED DURING COAST PERIOD
		
		TC	FLAG2DWN	# DISABLE FREE-FALL GYRO BIAS COMPENSATION
		OCT	40000		# (REMOVE DRIFT FLAG)
## Page 621
		TC	STATEUP		# SET BIAS FLAG
		OCT	04000
		
		CS	PIPTIME +1
		TS	TBASE5
		
		CAF	SIX
		TC	NEWPHASE
		OCT	00005
		
		CAF	BIT13		# IF TFF2 FLAG NOT SET, DO WHAT SERVICER
		MASK	STATE		#   WOULD HAVE DONE WHEN TFF = TFFMIN
		CCS	A
		TC	GO/ON		# TFF2 FLAG SET
		
		TC	SETBRNSW	# SET BURN TO SPS2 BACK UP SETTING
		OCT	00020
		
		TC	FLAG1UP		# SET INIT FLAG TO RE-MANEUVER TO SPS2 ATT
		OCT	00400
		
		CAF	ONE
		TS	VGCNTR
		
		CCS	REDOSPS1	# TFF2 FLAG DOWN, SEE IF DO SPS1 AGAIN
		TC	CONTINUE	# NO
		TC	CONTINUE
		TC	+1
		
		TC	SETBRNSW	# YES, SET BURN TO SPS1
		OCT	00010
		
		CAF	LOCSPS1
		TS	VRCADR
		
CONTINUE	CAF	THIRTY
		TC	NEWPHASE
		OCT	00004
		
		CS	TIME1
		TS	TBASE4
		
		CAF	2SEC24		# START READACCS IN 2 SECS
		TC	WAITLIST
		CADR	READACCS
		
		CAF	90SEC24		# SCHEDULE IGNITION IN 2 MINUTES
		TC	WAITLIST
		CADR	PLUSX2
## Page 622

		CAF	PRIO35
		TC	NOVAC
		CADR	MODE32
		
		TC	TASKOVER
		
GO/ON		CAF	THREE
		TC	NEWPHASE
		OCT	00002
		
		CS	ONE
		TC	NEWPHASE
		OCT	00004
		
		CAF	2SEC24		# TURN ON READACCS IN 2 SECS
		TC	WAITLIST
		CADR	READACCS
		
		CAF	PRIO35		# JOB TO CHANGE MM AND FINISH DRIFT COMP
		TC	NOVAC
		CADR	MODE26
		
GO/ON1		CAF	PRIO12		# DO ATTITUDE MANEUVER FOR SPS2 BURN
		TC	FINDVAC
		CADR	ATTIJOB1 -1
		
		TC	TASKOVER
		
2SEC24		DEC	200
90SEC24		DEC	9000
LOCSPS1		CADR	501SPS1
PIPCAD24	CADR	PIPASR



MODE32		TC	NEWMODE		# SET MAJOR MODE TO PRE-SPS2
		OCT	00032
		
		TC	POSTJUMP	# FINISH DRIFT COMPUTATIONS
		CADR	MODE26 +2



PLUSX2		CAF	18SEC24
		TC	WAITLIST
		CADR	GIMPOWON
		
		TC	STATEDWN	# REMOVE BIAS FLAG
		OCT	04000
## Page 623

		TC	RELAYON		# SET SCS +X TRANS DISCRETE (C27)
		OCT	40020
		
		CAF	SEVENTN
		TC	NEWPHASE
		OCT	4
		
		TC	TASKOVER
		
18SEC24		DEC	1800



MODE26		TC	NEWMODE		# SET MAJOR MODE TO HOLD SPS2 ATTITUDE
		OCT	00026		#   UNTIL TFFMIN
		
		TC	FLAG1UP		# SET INTP FLAG
		OCT	01000
		
		CS	PIPTIME +1	# CALL LASTBIAS ROUTINE
		COM
		TS	MPAC
		
		CAF	COMP2SEC
		TC	POSTJUMP
		CADR	LASTBIAS
		
COMP2SEC	DEC	200 B+6

## Page 624

		BANK	1
		
RELAYON		INDEX	Q
		CS	0
		INHINT
		MASK	DSPTAB +13D
		INDEX	Q
		AD	0
		TS	DSPTAB +13D
		RELINT
		INDEX	Q
		TC	1

RELAYOFF	INDEX	Q
		CS	0
		INHINT
		MASK	DSPTAB +13D
		AD	BIT15
		TS	DSPTAB +13D
		RELINT
		INDEX	Q
		TC	1

FLAG1UP		INDEX	Q
		CS	0
		INHINT
		MASK	FLAGWRD1
		INDEX	Q
		AD	0
		TS	FLAGWRD1
		RELINT
		INDEX	Q
		TC	1

FLAG1DWN	INDEX	Q
		CS	0
		INHINT
		MASK	FLAGWRD1
		TS	FLAGWRD1
		RELINT
		INDEX	Q
		TC	1

FLAG2UP		INDEX	Q
		CS	0
		INHINT
		MASK	FLAGWRD2
		INDEX	Q
		AD	0
		TS	FLAGWRD2
## Page 625
		RELINT
		INDEX	Q
		TC	1

FLAG2DWN	INDEX	Q
		CS	0
		INHINT
		MASK	FLAGWRD2
		TS	FLAGWRD2
		RELINT
		INDEX	Q
		TC	1

STATEUP		INDEX	Q
		CS	0
		INHINT
		MASK	STATE
		INDEX	Q
		AD	0
		TS	STATE
		RELINT
		INDEX	Q
		TC	1

STATEDWN	INDEX	Q
		CS	0
		INHINT
		MASK	STATE
		TS	STATE
		RELINT
		INDEX	Q
		TC	1

SETBRNSW	CS	BURNMASK
		INHINT
		MASK	FLAGWRD2
		INDEX	Q
		AD	0
		TS	FLAGWRD2
		RELINT
		INDEX	Q
		TC	1

BURNMASK	OCT	00177



SETHETAD	INHINT
		CS	CDUX
		COM
## Page 626
		TS	THETAD
		CS	CDUY
		COM
		TS	THETAD +1
		CS	CDUZ
		COM
		TS	THETAD +2
		RELINT
		TC	Q



NINE		DEC	9
ELEVEN		OCT	00013
11DEC		EQUALS	ELEVEN
TWELVE		OCT	00014
THIRTN		OCT	00015
THIRTEEN	EQUALS	THIRTN
FOURTN		OCT	00016
FIFTN		OCT	00017
SIXTN		OCT	00020
SEVENTN		OCT	00021
EIGHTN		OCT	00022
NINETEEN	DEC	19
TWENTY0		OCT	00024
TWENTY		EQUALS	TWENTY0
TWENTY1		OCT	00025
TWENTY2		OCT	00026
TWENTY3		OCT	00027
TWENTY4		OCT	00030
TWENTY5		OCT	00031

TWENTY6		DEC	26

TWENTY7		DEC	27

TWENTY8		DEC	28
TWENTY9		DEC	29
THIRTY		DEC	30
30DEC		EQUALS	THIRTY
THIRTY1		DEC	31
THIRTY2		DEC	32
FORTY		DEC	40
40DEC		EQUALS	FORTY
FIFTY		DEC	50
50DEC		EQUALS	FIFTY
SIXTY		DEC	60
60DEC		EQUALS	SIXTY
100DEC		DEC	100
200DEC		DEC	200
## Page 627
300DEC		DEC	300
400DEC		DEC	400
500DEC		DEC	500
600DEC		DEC	600
SIXHNDRD	EQUALS	600DEC
1000DEC		DEC	1000
2000DEC		DEC	2000
